﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Windows.Forms;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UITest.Extension;
using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;


namespace Emotive.DocumentUI.Test
{
    /// <summary>
    /// Summary description for CodedUITest1
    /// </summary>
    [CodedUITest]
    public class DocumentUI
    {
        public DocumentUI()
        {
        }

        [TestMethod]
        public void OpenDocumentSol()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.StartDesigner();
            this.UIMap.LoadDocumentSol();
            this.UIMap.ExpandPackSol();
        }

        [TestMethod]
        public void Doc_Add()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddP1Pack1NewDoc();
            this.UIMap.AddNewDoc1();
            this.UIMap.CheckNewDoc1();
        }

        [TestMethod]
        public void Doc_AddSameName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddP1Pack1NewDoc();
            this.UIMap.AddNewDoc1();
            this.UIMap.CheckWarningNewDoc1SameName();
            this.UIMap.ClickOKWarningSameDocName();
        }

        [TestMethod]
        public void Doc_AddWrongName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddP1Pack1NewDoc();
            this.UIMap.AddDocWrongName();
            this.UIMap.ClickCancelAddNewDoc();
        }

        [TestMethod]
        public void Doc_AddExisting()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddP1Pack1ExistingDoc1();
            this.UIMap.AddExistingDoc1();
            this.UIMap.CheckExistingDocument();
        }

        [TestMethod]
        public void Doc_AddExistingSameName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddP1Pack1ExistingDoc();
            this.UIMap.AddExistingDoc();
            this.UIMap.CheckExistingDocument1();

        }

        [TestMethod]
        public void Doc_AddExistingWrongName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddP1Pack1ExistingDoc();
            this.UIMap.AddExistingDocWrongName();
            this.UIMap.CheckWarningAddDocWrongName();
            this.UIMap.ClickOkWarningAddDocWrongName();
        }

        [TestMethod]
        public void Doc_OpenUnallocated()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.OpenUnallocatedDocExecutable();
            this.UIMap.CloseWinExplorer();
            this.UIMap.CheckUnallocatedDocExecutable();
            this.UIMap.OpenUnallocatedDocErrorAndSameName();
            this.UIMap.CloseWinExplorer();
            this.UIMap.CheckUnallocatedDocErrorUnexecutable();
            this.UIMap.CheckUnallocatedDocSameName();
            this.UIMap.OpenUnallocatedDocErrorUnexecutable();            
            this.UIMap.CheckWarningAddDocWrongName();
            this.UIMap.ClickOkWarningAddDocWrongName();
            this.UIMap.CloseWinExplorer();
        }

        [TestMethod]
        public void Doc_AddUnallocatedDoc()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            // chua lam do ko co project P3
        }

        [TestMethod]
        public void Doc_Validate()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            // chua lam do ko co project P3
        }

        [TestMethod]
        public void Doc_Rename()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.RenamePublicDoc();
            this.UIMap.CheckImportedPublicDoc();
            this.UIMap.OpenP1ImportPublicDoc1ProcMain();
            this.UIMap.ExecuteCurrentWF();
            this.UIMap.ClickOKConfirmDialog();

            this.UIMap.RenameImportedPublicDoc();
            this.UIMap.CheckPublicDoc();
            this.UIMap.OpenP2ImportPublicDoc2ProcMain();
            this.UIMap.ExecuteCurrentWF();
            this.UIMap.ClickOKConfirmDialog();
        }

        [TestMethod]
        public void Doc_RenameSameName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.RenamePublicDoc_A();
            this.UIMap.CheckWarningImportPubliDoc1SameName();
            this.UIMap.ClickOKWarningImportPublicDoc1SameName();
        }

        [TestMethod]
        public void Doc_RenameWrongName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.RenamePublicDoc_C();
            this.UIMap.ClickCancelRenameDoc();
        }

        [TestMethod]
        public void Doc_SaveDocOrSol1()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.RenameImportPublicDoc1ProcMain();
            this.UIMap.CheckImportPublicDoc1ProcMain1();
            this.UIMap.SelectMenuRenameImportPublicDoc2ProcMain();
            this.UIMap.RenameImportPublicDoc2ProcMain_1();
            this.UIMap.CheckImportPublicDoc2ProcMain1();
            this.UIMap.SaveP1ImportPublicDoc1();
            this.UIMap.ReloadDocSol();
            this.UIMap.ClickNoSaveChanges();
            this.UIMap.ExpandImportPublicDoc1P1();
            this.UIMap.CheckImportPublicDoc2ProcMain();
        }

        [TestMethod]
        public void Doc_SaveDocOrSol2()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.RenameImportPublicDoc2ProcMain1();
            this.UIMap.CheckImportPublicDoc1ProcMain2();
            this.UIMap.SelectMenuRenameImportPublicDoc2ProcMain();


        }

        #region Additional test attributes

        // You can use the following additional attributes as you write your tests:

        ////Use TestInitialize to run code before running each test 
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{        
        //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        //    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
        //}

        ////Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{        
        //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        //    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
        //}

        #endregion

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
        private TestContext testContextInstance;

        public UIMap UIMap
        {
            get
            {
                if ((this.map == null))
                {
                    this.map = new UIMap();
                }

                return this.map;
            }
        }

        private UIMap map;
    }
}
